package com.rao.travel.service.impl;

import com.github.pagehelper.PageHelper;
import com.rao.travel.dao.ProductDao;
import com.rao.travel.pojo.Product;
import com.rao.travel.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Srao
 * @version 1.0
 * @className ProductServiceImpl
 * @date 2019/10/25 13:09
 * @package com.rao.travel.service.impl
 * @description
 */
@Service
@Transactional
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;

    /*分页查询所有产品*/
    @Override
    public List<Product> findAll(Integer page, Integer pageSize) throws Exception {
        PageHelper.startPage(page, pageSize);
        return productDao.findAll();
    }

    /*保存一个产品*/
    @Override
    public void save(Product product) throws Exception {
        productDao.save(product);
    }
}
